package simu.utils;

import java.io.*;


public class MyDrive {
	
	//fields
	File file;
	
	//Constructors
	public MyDrive(String name) throws IOException{
		 this.file = new File(name);
		 if (file.exists()){
			 System.out.println("The file "+file+" already exist.");
		 }else{
			 System.out.println("Creating file with name: "+file);
		 }
	}
	
	//Methods
	public void writer() throws IOException{
		try{
			BufferedWriter bw = new BufferedWriter(new FileWriter(file));
			for (int i=0; i < 10; i++){
				bw.write("Fila numero " + i + "\n");
			}
			bw.flush();
		} catch (IOException ioe){
			ioe.printStackTrace();
		}
	}
	
	public void writer(String text) throws IOException{
		try{
			BufferedWriter bw = new BufferedWriter(new FileWriter(file));			
			bw.write(text);			
			bw.close();
		} catch (IOException ioe){
			ioe.printStackTrace();
		}
	}

	
}
